package com.bdqn.t330.ch12file.mybatis;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.t330.ch12file.entity.Right;
import com.bdqn.t330.ch12file.entity.RightEntity;
import com.bdqn.t330.ch12file.mapper.RightMapper;
import com.bdqn.t330.ch12file.servcie.RightService;
import org.apache.ibatis.annotations.Param;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;

@SpringBootTest
@RunWith(SpringRunner.class)
public class RightTester {

    @Resource
    RightMapper rightMapper;

    @Resource
    RightService rightService;

    @Test
    public void getRightListTest() {
        QueryWrapper<RightEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByAsc("right_code");
        //List<RightEntity> rightList = rightMapper.selectList(page,queryWrapper);
        IPage<RightEntity> page = new Page<>(1, 2);
        IPage<RightEntity> iPage = rightMapper.selectPage(page, queryWrapper);
        System.out.println(iPage);
    }

    @Test
    public void deleteByIdTest() {
        //int count = rightMapper.deleteById("L0604");
        int count = rightService.deleteByRightIdBiz("L0604");
        System.out.println(count);
    }
}
